use "$path\datasets\lagged_data.dta", clear




bandwidth_and_weights, depvar(ch_total_child_places_pc) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 ch_total_child_places_pc elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m1
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum ch_total_child_places_pc if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)



bandwidth_and_weights, depvar(total_child_places_pc) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 total_child_places_pc elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m2
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum total_child_places_pc if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)




bandwidth_and_weights, depvar(log_bevoelkerung) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 log_bevoelkerung elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m3
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum log_bevoelkerung if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)


bandwidth_and_weights, depvar(log_unter_14jahre) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 log_unter_14jahre elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m4
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum log_unter_14jahre if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)


bandwidth_and_weights, depvar(log_ueber65jahre) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 log_ueber65jahre elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m5
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum log_ueber65jahre if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)


bandwidth_and_weights, depvar(log_von15bis65jahre) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 log_von15bis65jahre elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m6
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum log_von15bis65jahre if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)



bandwidth_and_weights, depvar(log_totrev_pc) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 log_totrev_pc elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m7
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum log_totrev_pc if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)


bandwidth_and_weights, depvar(log_ts_pc) var(margin_1)  bwmethod(CCT) kernel(tri) degree(1) number_of_elec(num_of_obs)
ivreg2 log_ts_pc elected_women margin_1 inter_1   if abs(margin_1)<$bw_opt  [pw=weight] , r cluster(gkz ) partial(margin_1 inter_1 )

est store m8
estadd local bw "CCT"
estadd local degree "Linear"
estadd local bw_length  $bw_opt
unique gkz_legis_party if e(sample)
estadd local num_of_elections  `"`r(sum)'"'
sum log_ts_pc if e(sample)
estadd scalar  mean_depvar =r(mean)
estadd scalar sd_depvar =r(sd)

************************************************************************************************************************************



esttab  m1 m2 m3 m4 m5 m6 m7 m8 using TableA1/tableA1.txt, style(tab) replace order( ) mlabel(,none) ///
cells(b(label(coef.) star fmt(%8.3f) ) se(label((z)) par fmt(%6.3f))) ///
collabels(none) ///
keep (elected_women  ) ///
stats(bw bw_length degree N   N_clust mean_depvar sd_depvar , layout( @ @ @ @ @  `""@ (@)""' )  fmt( %~#s %9.2f %~# %9.0g %9.0g  %9.2f %9.2f  ) ///
labels("Bandwidth type" "Bandwidth size" "Polynomial"   "N"  "Municipalities" "Mean (SD)"  )) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
varlabels( elected_women "Female victory"   ) 


